package com.heima.user.controller.v1;

import com.heima.apis.user.ApUserRealnameControllerApi;
import com.heima.common.constants.user.AdminConstans;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController  implements ApUserRealnameControllerApi {
    /**
     * 按照状态分页查询用户列表
     *
     * @param dto
     * @return
     */

    @Autowired
    private ApUserRealnameService apUserRealnameService;
    @PostMapping("/list")
    @Override
    public PageResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        ResponseResult responseResult = apUserRealnameService.loadListByStatus(dto);
        return (PageResponseResult) responseResult;
    }

    /**
     * 审核通过
     *
     * @param dto
     * @return
     */
    @PostMapping("/authPass")
    @Override
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        ResponseResult responseResult = this.apUserRealnameService.updateStatusById(dto, AdminConstans.PASS_AUTH);
        return  responseResult;
    }

    /**
     * 审核失败
     *
     * @param dto
     * @return
     */
    @PostMapping("/authFail")
    @Override
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        ResponseResult responseResult = this.apUserRealnameService.updateStatusById(dto, AdminConstans.FAIL_AUTH);
        return responseResult;
    }
}
